package com.molichuxing.services.business.service.impl;

import com.molichuxing.framework.dto.Paged;
import com.molichuxing.services.business.dto.response.VehicleBizDto;
import com.molichuxing.services.business.dto.response.VehicleInfoBizDto;
import com.molichuxing.services.business.dto.response.VehicleModlemakeBizDto;
import com.molichuxing.services.business.dto.response.VehicleNameBizDto;
import com.molichuxing.services.business.service.VehicleBizService;
import com.molichuxing.services.infrastructure.convertor.Convert;
import com.molichuxing.services.infrastructure.dto.response.VehicleDto;
import com.molichuxing.services.infrastructure.dto.response.VehicleMakeDto;
import com.molichuxing.services.infrastructure.dto.response.VehicleModleDto;
import com.molichuxing.services.infrastructure.dto.response.VehiclePictureDto;
import com.molichuxing.services.infrastructure.service.VehicleMakeService;
import com.molichuxing.services.infrastructure.service.VehicleModleService;
import com.molichuxing.services.infrastructure.service.VehiclePictureService;
import com.molichuxing.services.infrastructure.service.VehicleService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;

/**
 * <p>
 * 车辆服务实现类
 * </p>
 */
@Service("vehicleBizService")
public class VehicleBizServiceImpl implements VehicleBizService {
    private static final Logger logger = LoggerFactory.getLogger(VehicleBizServiceImpl.class);

    @Resource
    private VehicleService vehicleService;

    @Resource
    private VehiclePictureService vehiclePictureService;

    @Resource
    private VehicleModleService vehicleModleService;

    @Resource
    private VehicleMakeService vehicleMakeService;

    @Override
    public String getVehicleName(Integer vehicleModelId) {
        // 根据车型id 获取车型表的车系
        VehicleDto vehicleDto = vehicleService.getVehicleByVehicleId(vehicleModelId);
        // 根据车系id 查询车系
        VehicleModleDto vehicleModleDto = vehicleModleService.getVehicleModleDtoById(vehicleDto.getSeriesId());
        // 根据子品牌id 获取子品牌名称
        VehicleMakeDto vehicleMakeDto = vehicleMakeService.getVehicleMakeDtoById(vehicleModleDto.getVehicleMakeId());
        StringBuffer buffer = new StringBuffer();
        buffer.append(vehicleMakeDto.getName()).append(vehicleModleDto.getName()).append(vehicleDto.getName());
        return buffer.toString();

    }

    @Override
    public Map<Integer, VehicleNameBizDto> getCarByModelNameList(List<Integer> vehicleModelIds) {
        Map<Integer, VehicleNameBizDto> dtoMap = new HashMap<Integer, VehicleNameBizDto>();
        if (vehicleModelIds != null && !vehicleModelIds.isEmpty()) {
            for (int i = 0; i < vehicleModelIds.size(); i++) {
                VehicleNameBizDto vehicleNameBizDto = new VehicleNameBizDto();
                // 车型
                VehicleDto vehicleDto = vehicleService.getVehicleByVehicleId(vehicleModelIds.get(i));
                if (vehicleDto != null) {
                    vehicleNameBizDto.setModelName(vehicleDto.getName());
                    // 车系
                    VehicleModleDto vehicleModleDto = vehicleModleService
                            .getVehicleModleDtoById(vehicleDto.getSeriesId());
                    if (vehicleModleDto != null) {
                        vehicleNameBizDto.setSeriesName(vehicleModleDto.getName());
                        vehicleNameBizDto.setWhiteFigure(vehicleModleDto.getWhiteFigure());
                        vehicleNameBizDto.setWhiteFigureTerminal(vehicleModleDto.getWhiteFigureTerminal());
                        // 子品牌
                        vehicleNameBizDto.setSubBrandName(
                                vehicleMakeService.getVehicleMakeDtoById(vehicleModleDto.getVehicleMakeId()).getName()); // 1、子品牌名称
                    }
                    // 图片
                    List<VehiclePictureDto> pictures = vehiclePictureService
                            .getVehiclePictureByVehicleId(vehicleModelIds.get(i));
                    if (pictures != null && !pictures.isEmpty()) {
                        for (VehiclePictureDto picture : pictures) {
                            if (picture.getIsWhiteBg()) {
                                vehicleNameBizDto.setWhiteFigure(picture.getServerUrl());
                                vehicleNameBizDto.setWhiteFigureTerminal(picture.getServerUrl());
                                break;
                            }
                        }
                    }
                }

                dtoMap.put(vehicleModelIds.get(i), vehicleNameBizDto);
            }
        }

        return dtoMap;
    }

    @Override
    public List<VehicleModlemakeBizDto> getVehicleModlemakeBizDto() {
        List<VehicleModlemakeBizDto> result = new ArrayList<>();
        List<VehicleMakeDto> vehicleMakeDtoList = vehicleMakeService.getVehicleMakeDto(0);
        if ((null != vehicleMakeDtoList) && (vehicleMakeDtoList.size() > 0)) {
            for (VehicleMakeDto vehicleMakeDto : vehicleMakeDtoList) {
                VehicleModlemakeBizDto makeBizDto = new VehicleModlemakeBizDto();

                makeBizDto.setId(vehicleMakeDto.getId());
                makeBizDto.setName(vehicleMakeDto.getName());
                List<VehicleModlemakeBizDto> vehicleMakeList = new ArrayList<>();
                List<VehicleModleDto> vehicleModleList = vehicleModleService
                        .getVehicleModleList(vehicleMakeDto.getId());
                if ((null != vehicleModleList && vehicleModleList.size() > 0)) {
                    for (VehicleModleDto vehicleModleDto : vehicleModleList) {
                        VehicleModlemakeBizDto ModleBizDto = new VehicleModlemakeBizDto();
                        ModleBizDto.setId(vehicleModleDto.getId());
                        ModleBizDto.setName(vehicleModleDto.getName());

                        List<VehicleDto> vehicleDtoList = vehicleService.getVehicleList(vehicleModleDto.getId());
                        List<VehicleModlemakeBizDto> vehicleList = new ArrayList<>();
                        if ((null != vehicleDtoList) && (vehicleDtoList.size() > 0)) {
                            for (VehicleDto vehicleDto : vehicleDtoList) {
                                VehicleModlemakeBizDto vehicleBizDto = new VehicleModlemakeBizDto();
                                vehicleBizDto.setId(vehicleDto.getId());
                                vehicleBizDto.setName(vehicleDto.getName());
                                vehicleList.add(vehicleBizDto);
                            }
                        }
                        ModleBizDto.setVehicleModlemake(vehicleList);
                        vehicleMakeList.add(ModleBizDto);
                    }
                }
                makeBizDto.setVehicleModlemake(vehicleMakeList);
                result.add(makeBizDto);
            }
        }
        return result;
    }

    @Override
    public List<VehicleModlemakeBizDto> getMaintenanceVehicleModlemakeBizDto(List<Integer> vehicleIdList) {
        List<VehicleModlemakeBizDto> result = new ArrayList<>();
        List<VehicleMakeDto> vehicleMakeDtoList = vehicleMakeService.getVehicleMakeDto(0);
        if ((null != vehicleMakeDtoList) && (vehicleMakeDtoList.size() > 0)) {
            for (VehicleMakeDto vehicleMakeDto : vehicleMakeDtoList) {
                VehicleModlemakeBizDto makeBizDto = new VehicleModlemakeBizDto();

                makeBizDto.setId(vehicleMakeDto.getId());
                makeBizDto.setName(vehicleMakeDto.getName());
                List<VehicleModlemakeBizDto> vehicleMakeList = new ArrayList<>();
                List<VehicleModleDto> vehicleModleList = vehicleModleService
                        .getVehicleModleList(vehicleMakeDto.getId());
                if ((null != vehicleModleList && vehicleModleList.size() > 0)) {
                    for (VehicleModleDto vehicleModleDto : vehicleModleList) {
                        VehicleModlemakeBizDto ModleBizDto = new VehicleModlemakeBizDto();
                        ModleBizDto.setId(vehicleModleDto.getId());
                        ModleBizDto.setName(vehicleModleDto.getName());

                        List<VehicleDto> vehicleDtoList = vehicleService.getVehicleList(vehicleModleDto.getId());
                        List<VehicleModlemakeBizDto> vehicleList = new ArrayList<>();
                        if ((null != vehicleDtoList) && (vehicleDtoList.size() > 0)) {
                            for (VehicleDto vehicleDto : vehicleDtoList) {
                                VehicleModlemakeBizDto vehicleBizDto = new VehicleModlemakeBizDto();
                                Integer id = vehicleDto.getId();
                                if(vehicleIdList.contains(id)){
                                    continue;
                                }
                                vehicleBizDto.setId(id);
                                vehicleBizDto.setName(vehicleDto.getName());
                                vehicleList.add(vehicleBizDto);
                            }
                        }
                        if(vehicleList.size() < 1){
                            continue;
                        }
                        ModleBizDto.setVehicleModlemake(vehicleList);
                        vehicleMakeList.add(ModleBizDto);
                    }
                }
                if(vehicleMakeList.size() < 1){
                    continue;
                }
                makeBizDto.setVehicleModlemake(vehicleMakeList);
                result.add(makeBizDto);
            }
        }
        return result;
    }

    @Override
    public List<VehicleModlemakeBizDto> getVehicleModlemakeBizDto(List<Integer> vehicleIds) {
        List<VehicleModlemakeBizDto> result = new ArrayList<>();
        List<VehicleMakeDto> vehicleMakeDtoList = vehicleMakeService.getVehicleMakeDto(0, vehicleIds);
        if ((null != vehicleMakeDtoList) && (vehicleMakeDtoList.size() > 0)) {
            for (VehicleMakeDto vehicleMakeDto : vehicleMakeDtoList) {
                VehicleModlemakeBizDto makeBizDto = new VehicleModlemakeBizDto();

                makeBizDto.setId(vehicleMakeDto.getId());
                makeBizDto.setName(vehicleMakeDto.getName());
                List<VehicleModlemakeBizDto> vehicleMakeList = new ArrayList<>();
                List<VehicleModleDto> vehicleModleList = vehicleModleService.getVehicleModleListAndVehicle(vehicleMakeDto.getId(), vehicleIds);
                if ((null != vehicleModleList && vehicleModleList.size() > 0)) {
                    for (VehicleModleDto vehicleModleDto : vehicleModleList) {
                        VehicleModlemakeBizDto ModleBizDto = new VehicleModlemakeBizDto();
                        ModleBizDto.setId(vehicleModleDto.getId());
                        ModleBizDto.setName(vehicleModleDto.getName());

                        List<VehicleDto> vehicleDtoList = vehicleService.getVehicleListByIds(vehicleModleDto.getId(), vehicleIds);
                        List<VehicleModlemakeBizDto> vehicleList = new ArrayList<>();
                        if ((null != vehicleDtoList) && (vehicleDtoList.size() > 0)) {
                            for (VehicleDto vehicleDto : vehicleDtoList) {
                                VehicleModlemakeBizDto vehicleBizDto = new VehicleModlemakeBizDto();
                                vehicleBizDto.setId(vehicleDto.getId());
                                vehicleBizDto.setName(vehicleDto.getName());
                                vehicleList.add(vehicleBizDto);
                            }
                        }
                        ModleBizDto.setVehicleModlemake(vehicleList);
                        vehicleMakeList.add(ModleBizDto);
                    }
                }
                makeBizDto.setVehicleModlemake(vehicleMakeList);
                result.add(makeBizDto);
            }
        }
        return result;
    }

    @Override
    public Map<Integer, String> getVehicleFullName(List<Integer> vehicleModelIds) {
        Map<Integer, String> vehicleNameMap = new HashMap<>();
        if (vehicleModelIds != null && !vehicleModelIds.isEmpty()) {
            for (int i = 0; i < vehicleModelIds.size(); i++) {
                StringBuffer buffer = new StringBuffer();
                // 根据车型id 获取车型表的车系
                VehicleDto vehicleDto = vehicleService.getVehicleByVehicleId(vehicleModelIds.get(i));
                if (vehicleDto != null) {
                    // 根据车系id 查询车系
                    VehicleModleDto vehicleModleDto = vehicleModleService
                            .getVehicleModleDtoById(vehicleDto.getSeriesId());
                    if (null != vehicleModleDto) {
                        // 根据子品牌id 获取子品牌名称
                        VehicleMakeDto vehicleMakeDto = vehicleMakeService
                                .getVehicleMakeDtoById(vehicleModleDto.getVehicleMakeId());
                        if (null != vehicleMakeDto) {
                            buffer.append(vehicleMakeDto.getName()).append(vehicleModleDto.getName())
                                    .append(vehicleDto.getName());
                        }
                    }
                }
                vehicleNameMap.put(vehicleModelIds.get(i), buffer.toString());
            }
        }
        return vehicleNameMap;
    }

    @Override
    public VehicleBizDto getVehicleBusBean(Integer vehicleModelId) {
        VehicleBizDto beanDto = new VehicleBizDto();
        // 车型基础信息
        VehicleDto vehicleDto = vehicleService.getVehicleByVehicleId(vehicleModelId);
        if (null == vehicleDto) {
            return beanDto;
        }
        // 根据车型id查询车型图片信息
        List<VehiclePictureDto> vehiclePictureDtoList = vehiclePictureService
                .getVehiclePictureByVehicleId(vehicleModelId);
        beanDto.setId(vehicleDto.getId());
        beanDto.setName(vehicleDto.getName());
        List<String> resList = null;
        if (vehiclePictureDtoList != null && !vehiclePictureDtoList.isEmpty()) {
            resList = new ArrayList<>();
            for (VehiclePictureDto b : vehiclePictureDtoList) {
                resList.add(b.getServerUrl());
            }
        }
        beanDto.setPictures(resList);
        return beanDto;
    }

    /**
     * 根据车型id查询
     *
     * @param vehicleModelId 车型id
     * @return
     */
    @Override
    public VehicleNameBizDto getCarByModel(Integer vehicleModelId) {
        VehicleNameBizDto result = null;
        // 车型
        VehicleDto vehicleDto = vehicleService.getVehicleByVehicleId(vehicleModelId);
        if (vehicleDto != null) {
            result = new VehicleNameBizDto();
            result.setModelName(vehicleDto.getName());
            result.setModelId(vehicleDto.getId());
            result.setYear(vehicleDto.getYear());
            // 车系
            VehicleModleDto vehicleModleDto = vehicleModleService.getVehicleModleDtoById(vehicleDto.getSeriesId());
            if (vehicleModleDto != null) {
                result.setSeriesId(vehicleModleDto.getId());
                result.setSeriesName(vehicleModleDto.getName());
                result.setWhiteFigure(vehicleModleDto.getWhiteFigure());
                result.setWhiteFigureTerminal(vehicleModleDto.getWhiteFigureTerminal());
                // 子品牌
                VehicleMakeDto vehicleMakeDto = vehicleMakeService.getVehicleMakeDtoById(vehicleModleDto.getVehicleMakeId());
                result.setSubBrandName(vehicleMakeDto.getName()); // 1、子品牌名称
                result.setSubBrandId(vehicleModleDto.getVehicleMakeId());
                result.setBrandName(vehicleMakeService.getVehicleMakeDtoById(vehicleMakeDto.getPid()).getName());
                result.setAbbreviation(vehicleMakeDto.getAbbreviation());
            }
            // 图片
            List<VehiclePictureDto> pictures = vehiclePictureService.getVehiclePictureByVehicleId(vehicleModelId);
            if (pictures != null && !pictures.isEmpty()) {
                for (VehiclePictureDto picture : pictures) {
                    if (picture.getIsWhiteBg()) {
                        result.setWhiteFigure(picture.getServerUrl());
                        result.setWhiteFigureTerminal(picture.getServerUrl());
                        break;
                    }
                }
            }
        }

        return result;
    }

    @Override
    public VehicleNameBizDto getCarByModelName(String vehicleModelName) {
        VehicleNameBizDto result = null;
        // 车型
        VehicleDto vehicleDto = vehicleService.getVehicleByVehicleName(vehicleModelName);
        if (vehicleDto != null) {
            result = new VehicleNameBizDto();
            result.setModelName(vehicleDto.getName());
            result.setModelId(vehicleDto.getId());
            // 车系
            VehicleModleDto vehicleModleDto = vehicleModleService.getVehicleModleDtoById(vehicleDto.getSeriesId());
            if (vehicleModleDto != null) {
                result.setSeriesId(vehicleModleDto.getId());
                result.setSeriesName(vehicleModleDto.getName());
                result.setWhiteFigure(vehicleModleDto.getWhiteFigure());
                result.setWhiteFigureTerminal(vehicleModleDto.getWhiteFigureTerminal());
                // 子品牌
                VehicleMakeDto vehicleMakeDto = vehicleMakeService.getVehicleMakeDtoById(vehicleModleDto.getVehicleMakeId());
                result.setSubBrandName(vehicleMakeDto.getName()); // 1、子品牌名称
                result.setSubBrandId(vehicleModleDto.getVehicleMakeId());
                result.setBrandName(vehicleMakeService.getVehicleMakeDtoById(vehicleMakeDto.getPid()).getName());
            }
        }

        return result;
    }

    @Override
    public List<VehicleMakeDto> getVehicleMakeByModleIds(List<Integer> vehicleModelIds) {
        List<VehicleDto> vehicleList = vehicleService.getVehicleByVehicleIds(vehicleModelIds);
        if ((null == vehicleList) || (vehicleList.size() == 0)) {
            return null;
        }
        List<Integer> vehicleIds = new ArrayList<>();
        for (VehicleDto vehicleDto : vehicleList) {
            vehicleIds.add(vehicleDto.getSeriesId());
        }
        List<VehicleModleDto> vehicleModelList = vehicleModleService.getVehicleModleDtoByIds(vehicleIds);
        if ((null == vehicleModelList) || (vehicleModelList.size() == 0)) {
            return null;
        }
        List<Integer> vehicleModelIdArray = new ArrayList<>();
        for (VehicleModleDto vehicleModleDto : vehicleModelList) {
            vehicleModelIdArray.add(vehicleModleDto.getVehicleMakeId());
        }
        List<VehicleMakeDto> vehicleMakeList = vehicleMakeService.getVehicleMakeDtoByIds(vehicleModelIdArray);
        if ((null == vehicleMakeList) || (vehicleMakeList.size() == 0)) {
            return null;
        }
        return vehicleMakeList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<VehicleMakeDto>(Comparator.comparingInt(VehicleMakeDto::getId))), ArrayList::new));
    }

    @Override
    public List<VehicleBizDto> getVehicleListByMakeId(Integer vehicleMakeId) {
        List<VehicleMakeDto> makeResultList = vehicleMakeService.getVehicleMakeDtoByMainId(vehicleMakeId);
        if (null == makeResultList || makeResultList.size() == 0) {
            return null;
        }
        List<VehicleModleDto> vehicleModelList = new ArrayList<>();
        for (VehicleMakeDto vehicleMakeDto : makeResultList) {
            List<VehicleModleDto> modelList = vehicleModleService.getVehicleModleList(vehicleMakeDto.getId());
            if ((null != modelList) && (modelList.size() > 0)) {
                vehicleModelList.addAll(modelList);
            }
        }
        List<VehicleDto> result = new ArrayList<>();
        for (VehicleModleDto vehicleModleDto : vehicleModelList) {
            List<VehicleDto> vehicleList = vehicleService.getVehicleList(vehicleModleDto.getId());
            if ((null != vehicleList) && (vehicleList.size() > 0)) {
                result.addAll(vehicleList);
            }
        }
        return Convert.toVehicleBizDto(result);
    }

    /**
     * 车型分页
     *
     * @param map
     * @param pageNum
     * @param pageSize
     * @return
     */
    @Override
    public Paged<VehicleInfoBizDto> getVehiclePage(Map<String, Object> map, Integer pageNum, Integer pageSize) {
        Paged<VehicleDto> vehiclePage = vehicleService.getVehiclePage(map, pageNum, pageSize);
        List<VehicleDto> vehicleBeanDtoList = vehiclePage.getList();
        if (null == vehicleBeanDtoList || vehicleBeanDtoList.size() == 0) {
            return new Paged<VehicleInfoBizDto>();
        }

        List<Integer> seriesIdList = new ArrayList<>();
        for (VehicleDto vehicleDto : vehicleBeanDtoList) {
            seriesIdList.add(vehicleDto.getSeriesId());
        }
        List<VehicleModleDto> vehicleModleList = vehicleModleService.getVehicleModleDtoByIds(seriesIdList);
        List<VehicleMakeDto> vehicleMakeList = null;
        List<VehicleMakeDto> vehicleMainMakeList = null;
        if (vehicleModleList != null && vehicleModleList.size() > 0) {
            List<Integer> makeIdList = new ArrayList<>();
            for (VehicleModleDto vehicleModleDto : vehicleModleList) {
                makeIdList.add(vehicleModleDto.getVehicleMakeId());
            }
            vehicleMakeList = vehicleMakeService.getVehicleMakeByIds(makeIdList);
        }

        if (vehicleMakeList != null && vehicleMakeList.size() > 0) {
            List<Integer> makePIdList = new ArrayList<>();
            for (VehicleMakeDto vehicleMakeDto : vehicleMakeList) {
                makePIdList.add(vehicleMakeDto.getPid());
            }
            vehicleMainMakeList = vehicleMakeService.getVehicleMakeByIds(makePIdList);
        }

        List<VehicleInfoBizDto> pagedReturnList = getPagedReturnList(vehicleBeanDtoList, vehicleModleList, vehicleMakeList, vehicleMainMakeList);
        return new Paged<VehicleInfoBizDto>(pagedReturnList, vehiclePage.getTotal(), pageSize);
    }

    private List<VehicleInfoBizDto> getPagedReturnList(List<VehicleDto> vehicleBeanDtoList,
                                                       List<VehicleModleDto> vehicleModleList, List<VehicleMakeDto> vehicleMakeList,
                                                       List<VehicleMakeDto> vehicleMainMakeList) {
        List<VehicleInfoBizDto> vehicleInfoList = Convert.toVehicleInfoBizDtoList(vehicleBeanDtoList);
        Map<Integer, VehicleModleDto> vehicleModleMap = null;
        if (vehicleModleList != null && vehicleModleList.size() > 0) {
            vehicleModleMap = vehicleModleList.stream().collect(Collectors.toMap(VehicleModleDto::getId, a -> a, (k1, k2) -> k1));
        }

        if (null == vehicleModleMap || vehicleModleMap.size() < 1) {
            return vehicleInfoList;
        }

        Map<Integer, VehicleMakeDto> vehicleMakeMap = null;
        if (vehicleMakeList != null && vehicleMakeList.size() > 0) {
            vehicleMakeMap = vehicleMakeList.stream().collect(Collectors.toMap(VehicleMakeDto::getId, a -> a, (k1, k2) -> k1));
        }

        Map<Integer, VehicleMakeDto> vehicleMainMakeMap = null;
        if (vehicleMainMakeList != null && vehicleMainMakeList.size() > 0) {
            vehicleMainMakeMap = vehicleMainMakeList.stream().collect(Collectors.toMap(VehicleMakeDto::getId, a -> a, (k1, k2) -> k1));
        }

        for (VehicleInfoBizDto vehicleInfoBizDto : vehicleInfoList) {
            Integer seriesId = vehicleInfoBizDto.getSeriesId();
            VehicleModleDto vehicleModleDto = vehicleModleMap.get(seriesId);
            if (null == vehicleModleDto) {
                continue;
            }
            Convert.toVehicleInfoBizDto(vehicleModleDto, vehicleInfoBizDto);
            if (null == vehicleMakeMap || vehicleMakeMap.size() < 1) {
                continue;
            }
            Integer vehicleMakeId = vehicleModleDto.getVehicleMakeId();
            VehicleMakeDto vehicleMakeDto = vehicleMakeMap.get(vehicleMakeId);
            if (null == vehicleMakeDto) {
                continue;
            }
            Convert.toVehicleInfoBizDto(vehicleMakeDto, vehicleInfoBizDto);
            if (null == vehicleMainMakeMap || vehicleMainMakeMap.size() < 1) {
                continue;
            }
            Integer pId = vehicleMakeDto.getPid();
            VehicleMakeDto vehicleMainMakeDto = vehicleMainMakeMap.get(pId);
            if (null == vehicleMainMakeDto) {
                continue;
            }
            Convert.toVehicleInfoBizMainDto(vehicleMainMakeDto, vehicleInfoBizDto);
        }
        return vehicleInfoList;
    }

    @Override
    public VehicleInfoBizDto getVehicleInfo(Integer id) {
        if (null == id) {
            return null;
        }

        VehicleDto vehicleDto = vehicleService.getVehicleByVehicleId(id);
        if (null == vehicleDto) {
            return null;
        }
        VehicleInfoBizDto vehicleInfoBizDto = Convert.toVehicleInfoBizDto(vehicleDto);

        VehicleModleDto vehicleModleDto = vehicleModleService.getVehicleModleDtoById(vehicleDto.getSeriesId());
        if (null == vehicleModleDto) {
            return vehicleInfoBizDto;
        }
        Convert.toVehicleInfoBizDto(vehicleModleDto, vehicleInfoBizDto);

        VehicleMakeDto vehicleMakeDto = vehicleMakeService.getVehicleMakeDtoById(vehicleModleDto.getVehicleMakeId());
        if (null == vehicleMakeDto) {
            return vehicleInfoBizDto;
        }
        Convert.toVehicleInfoBizDto(vehicleMakeDto, vehicleInfoBizDto);

        VehicleMakeDto vehicleMainMakeDto = vehicleMakeService.getVehicleMakeDtoById(vehicleMakeDto.getPid());
        if (null == vehicleMainMakeDto) {
            return vehicleInfoBizDto;
        }
        Convert.toVehicleInfoBizMainDto(vehicleMainMakeDto, vehicleInfoBizDto);

        List<VehiclePictureDto> pictures = vehiclePictureService.getVehiclePictureByVehicleId(id);
        if (null == pictures || pictures.size() < 1) {
            return vehicleInfoBizDto;
        }
        List<String> vehiclePictureList = pictures.stream().map(VehiclePictureDto::getServerUrl).collect(Collectors.toList());
        vehicleInfoBizDto.setVehiclePictureList(vehiclePictureList);
        return vehicleInfoBizDto;
    }


    /**
     * 获取所有车型信息（包含车系、品牌）
     *
     * @return
     */
    @Override
    public List<VehicleNameBizDto> getAllVehicle() {
        return vehicleService.getAllVehicleMake();
    }
}
